package com.example.demo.controller;
import com.example.demo.model.Qj;
import com.example.demo.service.IQjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 董婷
 */

@Api(tags = "请假管理")
@RestController
@RequestMapping("/swagger24")
public class qjController {
    @Autowired
    private IQjService qjService;
    @CrossOrigin
    @ApiOperation(value="对请假信息的添加方法")
    @PostMapping("/insertqj")
    public int insertQj(@RequestBody Qj qj){
        System.out.println("进入添加请假信息接口" );
        return qjService.insertQj(qj);
    }

    @PostMapping("/getAll")
    public List<Qj> getAllQj(@RequestBody Qj qj)
    {
        System.out.println("进入查询请假信息方法");
        List<Qj> listQj=qjService.getAllQj(qj);
        return listQj;
    }
    @PostMapping("/editQj")
    public int EditQj(@RequestBody Qj qj){
        System.out.println("添加修改请假信息方法");
        return qjService.updateQj(qj);
    }
    @GetMapping("/delQj")
    public int Delete(int qjid){
        System.out.println("进入删除请假信息方法");
        int returnValues=0;
        if(qjid!=0){
            Qj qj=new Qj();
            qj.setQjid(qjid);
            returnValues=qjService.deleteQj(qj);
        }
        return returnValues;
    }

    @GetMapping("/getOne")
    public Qj getQj(int qjid){
        Qj qj=new Qj();
        System.out.println("进入单条查询请假信息方法");
        if(qjid!=0){
            Qj qj1=new Qj();
            qj1.setQjid(qjid);
            qj=qjService.getQj(qj1);
            System.out.println("返回的数据集合为:"+qj.getQjid());
        }
        return qj;
    }








}
